
/**
  ******************************************************************************
  * Copyright 2021 The Microbee Authors. All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  * @file       xrce_dds.h
  * @author     baiyang
  * @date       2022-3-31
  ******************************************************************************
  */

#pragma once

#ifdef __cplusplus
extern "C"{
#endif

/*----------------------------------include-----------------------------------*/
#include <stdint.h>
#include <stdbool.h>

#include <rtconfig.h>

#include <uxr/client/client.h>
#include <ucdr/microcdr.h>
/*-----------------------------------macro------------------------------------*/
#ifndef XRCE_DDS_OBJECT_ID
#define XRCE_DDS_OBJECT_ID 1
#endif

#define ASSIGN_TOPIC_ID __xrce_dds_object_id_start++

#define XRCE_DDS_STREAM_HISTORY  1
#define XRCE_DDS_BUFFER_SIZE     UXR_CONFIG_CUSTOM_TRANSPORT_MTU * XRCE_DDS_STREAM_HISTORY
/*----------------------------------typedef-----------------------------------*/
typedef struct {
    uxrSession xrce_dds_session;

    uxrStreamId besteffort_in;
    uxrStreamId besteffort_out;

    uxrObjectId participant_id;

    uxrObjectId subscriber_id;
    uxrObjectId publisher_id;

    uxrCustomTransport xrce_dds_transport;

    uint8_t output_best_effort_stream_buffer[XRCE_DDS_BUFFER_SIZE];
    uint8_t input_reliable_stream_buffer[XRCE_DDS_BUFFER_SIZE];

    bool initialization;
} XrceDDS;
/*----------------------------------variable----------------------------------*/
extern uint16_t __xrce_dds_object_id_start;
extern XrceDDS xrce_dds;
/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/

/*------------------------------------test------------------------------------*/

#ifdef __cplusplus
}
#endif



